/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package cn.eonshine.base.config.security;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.subject.Subject;

import cn.eonshine.base.core.util.UserUtils;
import cn.eonshine.cuba.inf.modular.sys.entity.User;
import lombok.extern.log4j.Log4j;


/**
 * form validation (including verification code) filter class Form verification (including verification code) filter class 
 * @author jeeplus
 * @version 2014-5-19
 */
@Log4j
public class FormAuthenticationFilter extends org.apache.shiro.web.filter.authc.FormAuthenticationFilter {

	@Override
	protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request,
			ServletResponse response) throws Exception {
		HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
         
        User user = UserUtils.getUser();
         if(user != null) {
        	 log.info("用户 "+user.getAccount()+ " 登陆成功");
         }
         
        String url = this.getSuccessUrl();
        httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + url);    //页面跳转
        return false;
	}

}